package com.example.stroebackstage.filter;

import com.example.stroebackstage.entity.Administrator;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class Admin1Filter implements Filter {
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) request;
        HttpServletResponse resp = (HttpServletResponse) response;
        Administrator administrator = (Administrator) req.getSession().getAttribute("admin");
        if(administrator.getRoleId()==0||administrator.getRoleId()==1){
            chain.doFilter(req,resp);
        }
    }
}